<h4>KARTU RENCANA STUDI &raquo; <span class="current_page">ENTRI KARTU RENCANA STUDI</span></h4>

            <!-- Begin three column window -->
<div class="onecolumn" style="padding-bottom:20px">
    <div class="header">
    	<span><b>ENTRI KARTU RENCANA STUDI</b> : SEMESTER <?php echo $kontrol->SEMESTER.' '.$kontrol->TAHUN_AJARAN ?></span>
    </div>
	<br class="clear"/>
    <div class="content">
      <form method="post" name="mkform" action="<?php echo base_url().'siam/tambah-mk.html' ?>">
        <table align="left">
         <tr>
            <td><b>IP semester lalu</b></td>
            <td>:</td>
            <td><?php if($getDataKhs): ?><?php echo $this->gpa_com->ips($getDataKhs,'NILAI','SKS'); ?><?php else: ?>0.00<?php endif; ?></td>
         </tr>
        </table> <br />
        <table class="data" width="100%" cellpadding="0" cellspacing="0">
            <thead>
            <tr>
                <th width="30">No.</th>
                <th width="70">Kode MK</th>
                <th width="310">Nama MK</th>
                <th width="40">SKS</th>
                <th width="60">Kelas</th>
                <th width="60">BATAL</th>
                <th width="200">Keterangan</th>
            </tr>
            </thead>

            <?php $jumlah_sks_diambil = 0; ?>
            <?php $jamKuliahMkb = $this->akad_model->dataJamKuliah($matakuliahBaru->ID_TERSEDIA); ?>
            <?php $jamKuliahMkbRelated = $this->akad_model->jadwalKuliahRelated($matakuliahBaru->ID_TERSEDIA,$matakuliahBaru->PRODI,$matakuliahBaru->KODE_MK,$matakuliahBaru->KELAS,$matakuliahBaru->SEMESTER,$matakuliahBaru->TAHUN_AJARAN); ?>
            <?php $bentrok = 0; ?>
            <?php $seq_number = 1; ?>

            <?php if($krs): ?>

            <?php foreach($krs as $valueKrs): ?>
            <?php $jamKuliahKrsTemp = $this->akad_model->dataJamKuliah($valueKrs->ID);?>
            <?php $bentrok = $bentrok + $this->krs_library->cek_bentrok($jamKuliahKrsTemp, $jamKuliahMkb); ?>
            <?php $jamKuliahKrsTempRelated = $this->akad_model->jadwalKuliahRelated($valueKrs->ID,$valueKrs->KODE_PRODI,$valueKrs->KODE_MK,$valueKrs->KELAS,$valueKrs->SEMESTER,$valueKrs->TAHUN_AJARAN); ?>

            <?php if($jamKuliahKrsTempRelated): ?>
                    <?php foreach($jamKuliahKrsTempRelated as $keyKrs): ?>
                              <?php $jamKuliahKrsTempInline = $this->akad_model->dataJamKuliah($keyKrs->ID_MK_TERSEDIA); ?>
                              <?php $bentrok = $bentrok + $this->krs_library->cek_bentrok($jamKuliahKrsTempInline, $jamKuliahMkb); ?>
                    <?php endforeach ?>
            <?php endif ?>

            <?php if($jamKuliahMkbRelated): ?>
                    <?php foreach($jamKuliahMkbRelated as $key): ?>
                              <?php $jamKuliahMkbInline = $this->akad_model->dataJamKuliah($key->ID_MK_TERSEDIA); ?>
                              <?php $bentrok = $bentrok + $this->krs_library->cek_bentrok($jamKuliahKrsTemp, $jamKuliahMkbInline); ?>

                              <?php if($jamKuliahKrsTempRelated): ?>
                                  <?php foreach($jamKuliahKrsTempRelated as $keyKrs): ?>
                                            <?php $jamKuliahKrsTempInline = $this->akad_model->dataJamKuliah($keyKrs->ID_MK_TERSEDIA); ?>
                                            <?php $bentrok = $bentrok + $this->krs_library->cek_bentrok($jamKuliahKrsTempInline, $jamKuliahMkbInline); ?>
                                  <?php endforeach ?>
                              <?php endif ?>
                    <?php endforeach ?>
            <?php endif ?>

            <tbody>
            <tr align="center">
              <td align="right"><?php echo $seq_number ?>.</td>
              <td><?php echo strtoupper($valueKrs->KODE_MK); ?></td>
              <td align="left" style="padding-left:10px"><?php echo $valueKrs->NAMA_MK; ?></td>
              <td><?php echo $valueKrs->SKS ?></td>
              <td><?php echo $valueKrs->KELAS ?></td>
              <td><a href="<?php echo base_url().'siam/hapus-mk/'.$valueKrs->ID.'.html' ?>"><img src="<?php echo base_url().'images/batal-button.png' ?>" style="border-style:none" /></a></td>
              <td align="left" style="padding-left:10px"></td>
            </tr>

            <?php $seq_number++; ?>
            <?php $jumlah_sks_diambil = $jumlah_sks_diambil + $valueKrs->SKS; ?>
            <?php endforeach; ?>

            <?php endif; ?>

            <tr align="center">

              <?php $jumlah_sks_diambil = $jumlah_sks_diambil + $matakuliahBaru->SKS; ?>

              <?php $jumlah_sks_diambil_copy = $jumlah_sks_diambil; //variable ini untuk keperluan membatasi sks maksimum yg dpt diambil ?>

              <?php if( ($jumlah_sks_diambil) > ($this->gpa_com->maxSksDiambil($getDataKhs,'NILAI','SKS')) OR $bentrok == 1 ):?>
                      <?php $jumlah_sks_diambil = $jumlah_sks_diambil - $matakuliahBaru->SKS; ?>
              <?php endif; ?>

              <td align="right"><?php echo $seq_number ?>.</td>
              <td><?php echo strtoupper($matakuliahBaru->KODE_MK); ?></td>
              <td align="left" style="padding-left:10px"><?php echo $matakuliahBaru->NAMA_MK; ?></td>
              <td><?php echo $matakuliahBaru->SKS ?></td>
              <td><?php echo $matakuliahBaru->KELAS ?></td>
              <td><a href="<?php echo base_url().'siam/entri-krs.html' ?>"><img src="<?php echo base_url().'images/batal-button.png' ?>" style="border-style:none" /></a></td>
              <td align="left" style="padding-left:10px">
                 <?php if( ($jumlah_sks_diambil_copy) > ($this->gpa_com->maxSksDiambil($getDataKhs,'NILAI','SKS')) ):?>
                         <span class="alert">Ditolak! Kuota SKS tidak mencukupi</span>
                 <?php elseif($bentrok == 1):?>
                         <span class="alert">Ditolak! Bentrok dengan jadwal lain</span>
                 <?php endif; ?>
              </td>

            </tr>

            <tr align="center">
              <td height="20"></td>
              <td></td>
              <td align="right"><b>Jumlah SKS</b></td>
              <td><?php echo $jumlah_sks_diambil; ?></td>
              <td></td>
              <td></td>
              <td></td>
            </tr>
            <tr align="center">
              <td height="20"></td>
              <td></td>
              <td align="right"><b>Jumlah Maksimum SKS</b></td>
              <td><?php echo $this->gpa_com->maxSksDiambil($getDataKhs,'NILAI','SKS'); ?></td>
              <td></td>
              <td></td>
              <td></td>
            </tr>
  </tbody>
  </table>
  <div style="margin-left:15px">
  <table>
  <tr>
   <td><span style="color:red">PERHATIAN: Pastikan <b>KLIK SIMPAN</b> untuk mengunci matakuliah yang baru diambil. Jika tidak, matakuliah tidak akan tersimpan!</span></td>
  </tr>
  </table>
 </div>
<br /><br />
   <div align="center">
     <button class="sexybutton sexysimple sexyblue" type="submit" value="Simpan" name="simpan">Simpan</button>&nbsp;&nbsp;
     <button class="sexybutton sexysimple sexymagenta" type="button" value="Batal" name="batal" onclick="self.location='entri-krs.html'">Batal</button>
   </div>

<input name="nim" type="hidden" value="<?php echo $this->session->userdata('siamunp_user'); ?>" />

<?php if( ($jumlah_sks_diambil_copy) > ($this->gpa_com->maxSksDiambil($getDataKhs,'NILAI','SKS')) ):?>
           <input name="tersedia" type="hidden" value="0000" />
<?php elseif($bentrok == 1):?>
           <input name="tersedia" type="hidden" value="0000" />
<?php else : ?>
           <input name="tersedia" type="hidden" value="<?php echo $this->input->post('mk');?>" />
<?php endif; ?>
</form>

</div>

</div>